package com.hunk.core.web.resource;

import javax.servlet.ServletContext;

import org.springframework.web.context.ServletContextAware;

/** Description:<br>
 * 带版本的资源文件总路径
 * @author Hunk
 * @since 2013-5-3
 */
public class ResourcePathExposer implements ServletContextAware {

	private ServletContext servletContext;
	private String resourceRoot;
	
	public void init() {
		String version = "0.0.3";
		resourceRoot = "/resources-" + version;
		getServletContext()
			.setAttribute("resourceRoot", getServletContext().getContextPath()+resourceRoot);
	}

	@Override
	public void setServletContext(ServletContext servletContext) {
		this.servletContext = servletContext;
	}

	public ServletContext getServletContext() {
		return servletContext;
	}

	public String getResourceRoot() {
		return resourceRoot;
	}

	public void setResourceRoot(String resourceRoot) {
		this.resourceRoot = resourceRoot;
	}
}
